package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.R.R;
import net.wanho.dto.TransshipmentAddDTO;
import net.wanho.dto.TransshipmentConfirmDTO;
import net.wanho.dto.TransshipmentDTO;
import net.wanho.service.TransshipmentService;
import net.wanho.vo.PageInfo;
import net.wanho.vo.TransshipmentVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 这个类是：
 *
 * @author: MENG HU WANG
 * @date: 2025/2/7 9:44
 * @version: 1.0
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("transshipment")
public class TransshipmentController {
    private final TransshipmentService transshipmentService;


    // 分页查询
    @GetMapping("transshipment-page-list")
    public R transactionPage(@RequestParam(defaultValue = "1") int pageNum,
                             @RequestParam(defaultValue = "5") int pageSize,
                             TransshipmentDTO transshipmentDTO) {
        PageInfo<TransshipmentVo> pageInfo = transshipmentService.getPage(pageNum, pageSize, transshipmentDTO);

        return R.ok(pageInfo);
    }

    // 添加调货单
    @PostMapping("transshipment-add")
    public R addTransshipment(@RequestBody TransshipmentAddDTO transshipmentAddDTO) {
        transshipmentService.addTransshipment(transshipmentAddDTO);
        return R.ok("添加调货单成功！");
    }

    //确认调货
    @PutMapping("transshipment-confirm")
    public R confirmTransshipment(@RequestBody TransshipmentConfirmDTO confirmDTO) {
        transshipmentService.confirmTransshipment(confirmDTO);
        return R.ok("确认调货成功！");
    }
}
